//    Copyright (C) Kherty.  All rights reserved.
using System;
using System.Runtime.InteropServices;
using FILETIME=System.Runtime.InteropServices.ComTypes.FILETIME;
using STATSTG=System.Runtime.InteropServices.ComTypes.STATSTG;

namespace OpenLS.Spreadsheet.Formats.Biff
{
    [ComImport, InterfaceType(ComInterfaceType.InterfaceIsIUnknown), Guid("0000000B-0000-0000-C000-000000000046")]
    internal interface IStorage
    {
        [return: MarshalAs(UnmanagedType.Interface)]
        IStream CreateStream([In, MarshalAs(UnmanagedType.BStr)] string pwcsName,
                             [In, MarshalAs(UnmanagedType.U4)] int grfMode,
                             [In, MarshalAs(UnmanagedType.U4)] int reserved1,
                             [In, MarshalAs(UnmanagedType.U4)] int reserved2);

        [return: MarshalAs(UnmanagedType.Interface)]
        IStream OpenStream([In, MarshalAs(UnmanagedType.BStr)] string pwcsName,
                           IntPtr reserved1, [In, MarshalAs(UnmanagedType.U4)] int grfMode,
                           [In, MarshalAs(UnmanagedType.U4)] int reserved2);

        [return: MarshalAs(UnmanagedType.Interface)]
        IStorage CreateStorage([In, MarshalAs(UnmanagedType.BStr)] string pwcsName,
                               [In, MarshalAs(UnmanagedType.U4)] int grfMode,
                               [In, MarshalAs(UnmanagedType.U4)] int reserved1,
                               [In, MarshalAs(UnmanagedType.U4)] int reserved2);

        [return: MarshalAs(UnmanagedType.Interface)]
        IStorage OpenStorage([In, MarshalAs(UnmanagedType.BStr)] string pwcsName, IntPtr pstgPriority,
                             [In, MarshalAs(UnmanagedType.U4)] int grfMode, IntPtr snbExclude,
                             [In, MarshalAs(UnmanagedType.U4)] int reserved);

        void CopyTo(int ciidExclude, [In, MarshalAs(UnmanagedType.LPArray)] Guid[] pIIDExclude, IntPtr snbExclude,
                    [In, MarshalAs(UnmanagedType.Interface)] IStorage stgDest);

        void MoveElementTo([In, MarshalAs(UnmanagedType.BStr)] string pwcsName,
                           [In, MarshalAs(UnmanagedType.Interface)] IStorage stgDest,
                           [In, MarshalAs(UnmanagedType.BStr)] string pwcsNewName,
                           [In, MarshalAs(UnmanagedType.U4)] int grfFlags);

        void Commit(int grfCommitFlags);
        void Revert();

        void EnumElements([In, MarshalAs(UnmanagedType.U4)] int reserved1, IntPtr reserved2,
                          [In, MarshalAs(UnmanagedType.U4)] int reserved3,
                          [MarshalAs(UnmanagedType.Interface)] out object ppVal);

        void DestroyElement([In, MarshalAs(UnmanagedType.BStr)] string pwcsName);

        void RenameElement([In, MarshalAs(UnmanagedType.BStr)] string pwcsOldName,
                           [In, MarshalAs(UnmanagedType.BStr)] string pwcsNewName);

        void SetElementTimes([In, MarshalAs(UnmanagedType.BStr)] string pwcsName, [In] FILETIME pctime,
                             [In] FILETIME patime, [In] FILETIME pmtime);

        void SetClass([In] ref Guid clsid);
        void SetStateBits(int grfStateBits, int grfMask);
        void Stat([Out] STATSTG pStatStg, int grfStatFlag);
    }
}